<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>按钮执行JS示例</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
            margin: 0;
            background-color: #f5f5f5;
        }

        button {
            padding: 10px 20px;
            font-size: 16px;
            background-color: #4CAF50;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            transition: background-color 0.3s;
        }

            button:hover {
                background-color: #45a049;
            }
    </style>
</head>
<body>
    <button onclick="executeMethod()">点击执行方法</button>

    <script>
        function executeMethod() {
            var myHeaders = new Headers();
            myHeaders.append("Content-Type", "application/json");

            var raw = JSON.stringify({
                "Content": "^XA\n^FX Top section with logo, name and address.\n^CF0,60\n^FO50,50^GB100,100,100^FS\n^FO75,75^FR^GB100,100,100^FS\n^FO93,93^GB40,40,40^FS\n^FO220,50^FDIntershipping, Inc.^FS\n^CF0,30\n^FO220,115^FD1000 Shipping Lane^FS\n^FO220,155^FDShelbyville TN 38102^FS\n^FO220,195^FDUnited States (USA)^FS\n^FO50,250^GB700,3,3^FS\n\n^FX Second section with recipient address and permit information.\n^CFA,30\n^FO50,300^FDJohn Doe^FS\n^FO50,340^FD100 Main Street^FS\n^FO50,380^FDSpringfield TN 39021^FS\n^FO50,420^FDUnited States (USA)^FS\n^CFA,15\n^FO600,300^GB150,150,3^FS\n^FO638,340^FDPermit^FS\n^FO638,390^FD123456^FS\n^FO50,500^GB700,3,3^FS\n\n^FX Third section with bar code.\n^BY5,2,270\n^FO100,550^BC^FD12345678^FS\n\n^FX Fourth section (the two boxes on the bottom).\n^FO50,900^GB700,250,3^FS\n^FO400,900^GB3,250,3^FS\n^CF0,40\n^FO100,960^FDCtr. X34B-1^FS\n^FO100,1010^FDREF1 F00B47^FS\n^FO100,1060^FDREF2 BL4H8^FS\n^CF0,190\n^FO470,955^FDCA^FS\n^XZ",
                "Copies": 1
            });

            var requestOptions = {
                method: 'POST',
                headers: myHeaders,
                body: raw,
                redirect: 'follow'
            };
	    for(let i = 0;i<10;i++){

            	fetch("http://127.0.0.1:8888/API/Print", requestOptions)
                	.then(response => response.text())
               	 	.then(result => console.log(result))
                	.catch(error => console.log('error', error));
            	console.log("按钮被点击，方法已执行");
	  }
        }
    </script>
</body>
</html>